function getVirtualData(rawData) {
    const data = [];
    rawData.forEach(element => {
        data.push([
            element.date,
            element.pct
        ]);
    });
    return data;
}

let option = {
    tooltip: {
        position: 'top',
        formatter: function (p) {
          return p.data[0] + ': ' + p.data[1];
        }
    },
    visualMap: {
        pieces: [
            { min: -100, max: -10, label: '< -10', color: '#4682B4' },
            { min: -10, max: -5, label: '< -5', color: '#008B00' },
            { min: -5, max: -3, label: '< -3', color: '#00CD00' },
            { min: -3, max: 0, label: '< 0', color: '#C1FFC1' },
            { min: 0, max: 3, label: '> 0', color: '#FFC0CB' },
            { min: 3, max: 5, label: '> 3', color: '#FF4040' },
            { min: 5, max: 10, label: '> 5', color: '#FFA500' },
            { min: 10, max: 100, label: '>10', color: '#CD6600' }
          ],
        type: 'piecewise',
        orient: 'horizontal',
        left: 'center',
        top: 20
    },
    calendar: [
    {
        top: 100,
        right: 30,
        cellSize: ['auto', 18],
        range: '2025',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true ,
            position: 'left'
        }
    },
    {
        top: 300,
        right: 30,
        cellSize: ['auto', 18],
        range: '2024',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true,
            position: 'left'
         }
    },
    {
        top: 500,
        right: 30,
        cellSize: ['auto', 18],
        range: '2023',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true,
            position: 'left'
         }
    },
    {
        top: 700,
        right: 30,
        cellSize: ['auto', 18],
        range: '2022',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true,
            position: 'left'
         }
    },
    {
        top: 900,
        right: 30,
        cellSize: ['auto', 18],
        range: '2021',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true,
            position: 'left'
         }
    },
    {
        top: 1100,
        right: 30,
        cellSize: ['auto', 18],
        range: '2020',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true,
            position: 'left'
         }
    },
    {
        top: 1300,
        right: 30,
        cellSize: ['auto', 18],
        range: '2019',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true,
            position: 'left'
         }
    },
    {
        top: 1500,
        right: 30,
        cellSize: ['auto', 18],
        range: '2018',
        itemStyle: {
            borderWidth: 0.5
        },
        yearLabel: { 
            show: true,
            position: 'left'
         }
    },
    ],
    series: [
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 0,
        data: []
    },
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 1,
        data: []
    },
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 2,
        data: []
    },
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 3,
        data: []
    },
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 4,
        data: []
    },
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 5,
        data: []
    },
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 6,
        data: []
    },
    {
        type: 'heatmap',
        coordinateSystem: 'calendar',
        calendarIndex: 7,
        data: []
    },
    ]
};

export function builtStockPctHeatMap(rawData) {
    let data = getVirtualData(rawData);
    option.series[0].data =  data
    option.series[1].data = data;
    option.series[2].data = data;
    option.series[3].data = data;
    option.series[4].data = data;
    option.series[5].data = data;
    option.series[6].data = data;
    option.series[7].data = data;
    return option
}